﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace carportal
{
    public partial class MyProfile : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
             
        }

        protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e)
        {
         
        }

        protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            FileUpload f = (FileUpload)FormView1.FindControl("FileUpload1");
            TextBox t = (TextBox)FormView1.FindControl("TextBox1");
            if (f.HasFile)
            {
                string fileext = f.FileName.Substring(f.FileName.LastIndexOf(".") + 1);
                f.SaveAs((Server.MapPath("~/UserImages/") + "user_" + Session["UserID"] + "." + fileext));
                SqlDataSource1.UpdateParameters["image_address"].DefaultValue = "~/UserImages/user_" + Session["UserID"] + "." + fileext;
            }
            else
            {
                SqlDataSource1.UpdateParameters["image_address"].DefaultValue = t.Text;                
            }
        }
 
    }
}